home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
- Subject: v20i098: parseargs - functions to parse command line arguments, Patch07
- Message-ID: <1991Jul16.020707.23139@sparky.IMD.Sterling.COM>
- X-Md4-Signature: df35b50f2b3e5e4092f7f89aa648c0c1
- Date: Tue, 16 Jul 1991 02:07:07 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
- Posting-number: Volume 20, Issue 98
- Archive-name: parseargs/patch07
- Environment: UNIX, VMS, MS-DOS, OS/2, Amiga
- Patch-To: parseargs: Volume 17, Issue 46-57
-
- This is patch07 of parseargs. It introduces a few minor changes to parseargs.
- They are as follows:
-
- - fixed the "Intro" file to correctly show how to invoke parseargs(3)
- (the arguments where in the wrong order).
- - added stuff in #ifdef UNWRITABLE_STRING_LITERALS to work for machines
- and compilers that dont allow the programmer to modify string literals.
- - documented in the README file, all the various compile-time constants
- that may change the behavior of parseargs.
- - sparseargs neglected to free the argument-vector when it was done
- using it.
-
- To apply this patch:
-
- 1) cd to your parseargs directory
- 2) unshar this file into that directory (this will create the file PATCH07)
- 3) type "patch -p0 <PATCH07"
-
- ______________________ "And miles to go before I sleep." ______________________
- Brad Appleton Harris Corp., Computer Systems Division
- Software Engineer 2101 West Cypress Creek Road, M/S 161
- brad@ssd.csd.harris.com Fort Lauderdale, FL 33309-1892 USA
- ...!uunet!travis!brad Phone: (305) 973-5190
- ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of shell archive."
- # Contents: PATCH07
- # Wrapped by brad@hcx2 on Mon Jul 15 10:35:04 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'PATCH07' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'PATCH07'\"
- else
- echo shar: Extracting \"'PATCH07'\" \(10057 characters\)
- sed "s/^X//" >'PATCH07' <<'END_OF_FILE'
- X*** Intro.OLD Mon Jul 15 10:28:10 1991
- X--- Intro Wed Jun 5 10:38:05 1991
- X***************
- X*** 73,79 ****
- X Once the above array/string is declared it is a simple matter to invoke
- X parseargs from C as in the following example:
- X
- X! status = parseargs( argdesc_array, argv );
- X
- X or from a shell script as in the following example:
- X
- X--- 73,79 ----
- X Once the above array/string is declared it is a simple matter to invoke
- X parseargs from C as in the following example:
- X
- X! status = parseargs( argv, argdesc_array );
- X
- X or from a shell script as in the following example:
- X
- X*** README.OLD Mon Jul 15 10:28:33 1991
- X--- README Fri Jun 21 10:10:30 1991
- X***************
- X*** 332,338 ****
- X name for shell scripts. Furthermore, I changed the contents of USAGECNTL
- X from a number to a sequence of mnemonic strings (for better readability).
- X I also made USAGECNTL control whether or not a command-description is
- X! printed and whther or not the message is piped to a pager on Unix.
- X
- X Under VMS, the global symbol USAGECNTL is used in lieu of an environment
- X variable. See the parseargs(3) and parseargs(1) manual pages for more
- X--- 332,338 ----
- X name for shell scripts. Furthermore, I changed the contents of USAGECNTL
- X from a number to a sequence of mnemonic strings (for better readability).
- X I also made USAGECNTL control whether or not a command-description is
- X! printed and whether or not the message is piped to a pager on Unix.
- X
- X Under VMS, the global symbol USAGECNTL is used in lieu of an environment
- X variable. See the parseargs(3) and parseargs(1) manual pages for more
- X***************
- X*** 360,367 ****
- X Programs that use parseargs may be given default arguments under UNIX
- X and PCs through the use of environment variables (symbols are used for
- X VMS systems). If a C-program or a shell-script uses parseargs to imple-
- X! ment a command named "foo" then the environment variable (or global
- X! synbol) FOO_ARGS will be parsed for any "default" arguments before argv
- X is parsed. Argv will over-ride any options that are specified in
- X FOO_ARGS (except that ARGLISTs and ARGVECs set in FOO_ARGS will be
- X appended from argv[]).
- X--- 360,367 ----
- X Programs that use parseargs may be given default arguments under UNIX
- X and PCs through the use of environment variables (symbols are used for
- X VMS systems). If a C-program or a shell-script uses parseargs to imple-
- X! -ment a command named "foo" then the environment variable (or global
- X! symbol) FOO_ARGS will be parsed for any "default" arguments before argv
- X is parsed. Argv will over-ride any options that are specified in
- X FOO_ARGS (except that ARGLISTs and ARGVECs set in FOO_ARGS will be
- X appended from argv[]).
- X***************
- X*** 765,770 ****
- X--- 765,797 ----
- X AT&T Unix Systems using both ANSI and non-ANSI C Compilers.
- X
- X
- X+ COMPILE-TIME CONSTANTS
- X+ ======================
- X+ If any of the following macros are #defined at compile time then they will
- X+ have the following effect:
- X+
- X+ USE_PAGER -- for Unix systems only. Parseargs will include the code
- X+ which pipes usage messages to a paging program
- X+
- X+ NOFLOAT -- Parseargs will NOT include the code for the predefined
- X+ floating point arg-types argFloat() and argDouble().
- X+
- X+ SVR4 -- Parseargs(1) with the -M option will generate the new
- X+ Style Unix manual template.
- X+
- X+ USE_CURSES
- X+ USE_TERMINFO
- X+ USE_TERMCAP -- Parseargs will use curses/terminfo/termcap when trying
- X+ to figure out the size of the screen.
- X+
- X+ UNWRITABLE_STRING_LITERALS
- X+ -- This should be used only for compilers and/or machines
- X+ that do NOT allow the programmer to modify the contents
- X+ of string literals such as "hello, world". If this
- X+ constant is #defined, then all modified strings will be
- X+ duplicated (using strdup()) before they are changed.
- X+
- X+
- X IBM-PC VERSION OF parseargs(3)
- X ==============================
- X I also added ibm_args.c for MS-DOS and OS/2.
- X***************
- X*** 794,803 ****
- X ===============================
- X I also added vms_args.c for VAX/VMS.
- X
- X! VMS_ARGS.C HAS NOT BEEN TESTED ON A VMS SYSTEM!!! I did not have one
- X! to test it on. It should accept command-line arguments as described in
- X! the "Grammar Rules" section of the VAX manual but I cant guarantee
- X! anything so you'll have to test it out for yourself.
- X
- X ARGLIST and ARGVEC are comma-separated lists in the VMS version of
- X parseargs (not whitespace separated lists). In order to preserve a
- X--- 821,831 ----
- X ===============================
- X I also added vms_args.c for VAX/VMS.
- X
- X! vms_args.c has been tested by people (other than myself) on a VAX/VMS
- X! system and seems to work okay. It does not use the CLI$XXXXX routines
- X! for parsing. It should accept command-line arguments as described in
- X! the "Grammar Rules" section of the VAX manual with one slight exception
- X! which is noted below.
- X
- X ARGLIST and ARGVEC are comma-separated lists in the VMS version of
- X parseargs (not whitespace separated lists). In order to preserve a
- X***************
- X*** 890,901 ****
- X
- X Thanx also to Jim Barbour for helping me with some VMS specific things
- X (like getting the original, unparsed command-line from DCL and
- X! retreiving the value of a symbol), and to Tom Christiansen and Raymond
- X Chen for their help in getting parseargs(1) to work for perl scripts.
- X
- X! Thanx also to Gillmer J. Derge, Marco Nijdam, & Chris Johnston for sending
- X! me their bug reports and fixes so that I could incorporate them into the
- X! latest patch of parseargs.
- X
- X Lastly, thanks to all those who use and will continue to improve
- X parseargs, all I ask is that you keep me updated of your efforts (so I
- X--- 918,929 ----
- X
- X Thanx also to Jim Barbour for helping me with some VMS specific things
- X (like getting the original, unparsed command-line from DCL and
- X! retrieving the value of a symbol), and to Tom Christiansen and Raymond
- X Chen for their help in getting parseargs(1) to work for perl scripts.
- X
- X! Thanx also to Gillmer J. Derge, Marco Nijdam, Chris Johnston, & Earl Chew
- X! for sending me their bug reports and fixes so that I could incorporate them
- X! into the latest patch of parseargs.
- X
- X Lastly, thanks to all those who use and will continue to improve
- X parseargs, all I ask is that you keep me updated of your efforts (so I
- X*** doc/parseargs.man1.OLD Mon Jul 15 10:30:33 1991
- X--- doc/parseargs.man1 Tue Jun 18 17:10:00 1991
- X***************
- X*** 219,225 ****
- X message printed and execution terminated). Specifying \fB\-1\fP will force
- X all non-positional parameters to precede any positional parameters on the
- X command-line (hence anything on the command-line after a positional parameter
- X! that resembles a keyword parameter will nevertheles be interpreted as a
- X positional parameter).
- X .\"----------------------------------------------------------------
- X .so argvalopt.inc
- X--- 219,225 ----
- X message printed and execution terminated). Specifying \fB\-1\fP will force
- X all non-positional parameters to precede any positional parameters on the
- X command-line (hence anything on the command-line after a positional parameter
- X! that resembles a keyword parameter will nevertheless be interpreted as a
- X positional parameter).
- X .\"----------------------------------------------------------------
- X .so argvalopt.inc
- X*** patchlevel.h.OLD Mon Jul 15 10:32:11 1991
- X--- patchlevel.h Mon Jul 15 10:18:26 1991
- X***************
- X*** 2,7 ****
- X--- 2,18 ----
- X ** ^FILE: patchlevel.h - current patchlevel for parseargs
- X **
- X ** ^HISTORY:
- X+ ** 06/05/91 Brad Appleton <brad@ssd.csd.harris.com>
- X+ ** Patch07
- X+ ** - fixed the "Intro" file to correctly show how to invoke parseargs(3)
- X+ ** (the arguments where in the wrong order).
- X+ ** - added stuff in #ifdef UNWRITABLE_STRING_LITERALS to work for machines
- X+ ** and compilers that dont allow the programmer to modify string literals.
- X+ ** - documented in the README file, all the various compile-time constants
- X+ ** that may change the behavior of parseargs.
- X+ ** - sparseargs neglected to free the argument-vector when it was done
- X+ ** using it.
- X+ **
- X ** 05/11/91 Brad Appleton <brad@ssd.csd.harris.com>
- X ** Patch06
- X ** - parsecntl(3) now correctly handles mispelled keywords for the
- X***************
- X*** 80,86 ****
- X
- X #define VERSION 2
- X #define REVISION 0
- X! #define PATCHLEVEL 6
- X
- X #ifdef __STDC__
- X static const char
- X--- 91,97 ----
- X
- X #define VERSION 2
- X #define REVISION 0
- X! #define PATCHLEVEL 7
- X
- X #ifdef __STDC__
- X static const char
- X***************
- X*** 87,90 ****
- X #else
- X static char
- X #endif
- X! _Ident[] = "@(#)parseargs 2.0 patchlevel 6";
- X--- 98,101 ----
- X #else
- X static char
- X #endif
- X! _Ident[] = "@(#)parseargs 2.0 patchlevel 7";
- X*** xparse.c.OLD Mon Jul 15 10:33:49 1991
- X--- xparse.c Wed Jun 19 09:38:14 1991
- X***************
- X*** 542,547 ****
- X--- 542,551 ----
- X if (ARG_isBOOLEAN(ad) || ARG_isPSEUDOARG(ad))
- X BSET( arg_flags(ad), ARGNOVAL );
- X
- X+ #ifdef UNWRITABLE_STRING_LITERALS
- X+ ad->ad_prompt = strdup( ad->ad_prompt );
- X+ #endif
- X+
- X description = get_description( (char *)arg_sname(ad) );
- X if ( description ) {
- X BSET(arg_flags(ad), ARGDESCRIBED);
- X***************
- X*** 576,581 ****
- X--- 580,589 ----
- X }
- X #endif
- X
- X+ #ifdef UNWRITABLE_STRING_LITERALS
- X+ cmd_name(argd) = strdup( cmd_name(argd) );
- X+ #endif
- X+
- X /* if new-style, get the purpose from the command name */
- X if ( !old_style && cmd_name(argd) ) {
- X purpose = get_description( (char *)cmd_name(argd) );
- X***************
- X*** 1881,1886 ****
- X--- 1889,1895 ----
- X }
- X
- X rc = parse_argv_style( argv, parse_init( &argd ) );
- X+ free( argv );
- X
- X /* scan for missing required arguments */
- X if ( SYNTAX_ERROR(rc, argd) ) {
- END_OF_FILE
- if test 10057 -ne `wc -c <'PATCH07'`; then
- echo shar: \"'PATCH07'\" unpacked with wrong size!
- fi
- # end of 'PATCH07'
- fi
- echo shar: End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-